﻿@model CoralNode.Core.Entity.Domains.Site.MenuDomain

<div id="pbody" class="pbody_style2">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_setting"></span><span class="t t_c">快速设置</span>
        </div>

        <div id="main">
            <div class="step">
                <ul>
                    <li><span class="ico ico_step_over"></span><span class="t">基本信息</span>
                    </li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_over"></span><span class="t">扩展信息</span></li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_over"></span><span class="t">内容结构</span></li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_current"></span><span class="t">菜单结构</span></li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_noover"></span><span class="t">网站外观</span></li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_noover"></span><span class="t">权限设置</span></li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_noover"></span><span class="t">性能设置</span></li>
                    <li><i></i></li>
                    <li><span class="ico ico_step_noover"></span><span class="t">完成</span></li>
                </ul>
            </div>

            <div class="form_main step_content pl_8">
                <div class="tablelist_style1">
                    <table cellpadding="0" cellspacing="0">
                        @foreach (var item in ViewBag.MenuList) {
                            <tr>
                                @if (item.ParentId > 0) {
                                    <td><span class="ico ico_child ml_@item.Path"></span>@item.Title</td>
                                } else {
                                    <td><b>@item.Title</b></td>
                                }
                                <td class="align_r">
                                    <div itemid="@item.Id" class="fun">
                                        <a type="up" href="#">向上插入菜单</a>
                                        <a type="down" href="#">向下插入菜单</a>
                                        <a type="child" href="#">插入子菜单</a>
                                    </div>
                                </td>
                            </tr>
                        }
                    </table>
                </div>
                <form id="spform" action="/m/quickSetting/SettingMenu" method="POST">
                    <div class="createsettingMenu js-showMenu">
                        <div class="cnt table_form form_main clearfix">
                            <div class="clearfix">
                                <div class="w_25-5">
                                    <table>
                                        <tr>
                                            <td>
                                                @Html.TextBoxFor(m => m.Title, new { @class = "text w_24 js-watermark required", @msg = "菜单名称" })
                                                @Html.HiddenFor(m => m.SiteId)
                                                <input type="hidden" name="Group.Id" value="@ViewBag.Group.Id"/>
                                                <input type="hidden" name="type" class="js-type" value="" />
                                                <input type="hidden" name="refId" class="js-refId" value="0" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                @Html.TextBoxFor(m => m.Path, new { @class = "text w_24 js-watermark required", @msg = "菜单路径" })
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="select_owner w_24-5 " data-meta="{name:'MenuType',value:'@Model.MenuType',fun:'selectType', btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>'}">
                                                    <ul>
                                                        @foreach (var item in @ViewBag.MenuTypeList) {
                                                            if (Model.MenuType == @item.Value) { 
                                                            <li data-value="@item.Value">@item.Key
                                                            </li>
                                                            } else {
                                                            <li data-value="@item.Value">@item.Key
                                                            </li>
                                                            }
                                                        }
                                                    </ul>
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <div class="f_l menusetting_des">
                                    <table>
                                        <tr>
                                            <td>
                                                <label class="f_l">模版：</label>
                                                @Html.TextBoxFor(m => m.Templet, new { @class = "text w_24 js-watermark required", @msg = "模板名称" })
                                            </td>
                                        </tr>
                                        <tr class="js-menu-type">
                                            <td menu-type="1"></td>
                                            <td menu-type="2">
                                                <label class="f_l">分类：</label>
                                                <div class="ztreeContainer">
                                                    @Html.TextBox("CategoryTitle", string.Empty, new { @class = "text w_24 js_ztree_trigger" })
                                                    @Html.Hidden("CategoryId", string.Empty)
                                                    <ul class="ztree" style="width: 236px; left: 36px;"></ul>
                                                    <textarea class="js_ztree_data">@ViewBag.ZtreeCategory</textarea>
                                                </div>
                                            </td>
                                            <td menu-type="3">
                                                <label class="f_l">标签：</label><div class="select_owner w_25 " data-meta="{value:'@Model.TagId',name:'TagId', btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>'}">
                                                    <ul>
                                                        @if (ViewBag.TagList == null || ViewBag.TagList.Length == 0) { 
                                                            <li data-value="0">请选择标签
                                                            </li>
                                                        }
                                                        @foreach (var item in @ViewBag.TagList) {
                                                           
                                                            <li data-value="@item.Id">@item.Title
                                                            </li>
                                                        }
                                                    </ul>
                                                </div>
                                            </td>
                                            <td menu-type="4">
                                                <label class="f_l">原型：</label>
                                                <div class="select_owner w_25 " data-meta="{value:'@Model.PrototypeId',name:'PrototypeId', btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>'}">
                                                    <ul>
                                                        @if (ViewBag.PrototypeList == null || ViewBag.PrototypeList.Count == 0) { 
                                                            <li data-value="0">请选择原型
                                                            </li>
                                                        }
                                                        @foreach (var item in @ViewBag.PrototypeList) {
                                                            <li data-value="@item.Id">@item.Title
                                                            </li>
                                                        }
                                                    </ul>
                                                </div>
                                            </td>
                                            <td menu-type="5">
                                                <label class="f_l">外链：</label>
                                                <table class="f_l" style="width: 340px; margin-top: -7px;">
                                                    <tr style="position: relative; z-index: 2;">
                                                        <th width="100">
                                                            <label class="js_link_menu">
                                                                <input type="radio" name="linkMenu.LinkType" class="mt_0-5 mr_0-5" value="2" />跳转到菜单：</label>
                                                        </th>
                                                        <td width="200">
                                                            <div class="ztreeContainer_GotoMenu">
                                                                <input type="text" name="" class="text w_20" /><input type="hidden" value="" name="linkMenu.Value" /><ul
                                                                    class="ztree"></ul>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr style="position: relative; z-index: 1;">
                                                        <th width="100">
                                                            <label class="js_link_url">
                                                                <input type="radio" name="linkMenu.LinkType" class="mt_0-5 mr_0-5" value="1" />跳转到网址：</label>
                                                        </th>
                                                        <td>
                                                            <input type="text" name="linkMenu.Value" class="text w_20" value="http://" />
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                            <label class="submit mt_1" style="float: none">
                                <input type="submit" class="btn_2 f_r" value="添加" /></label>
                        </div>
                    </div>
                </form>
            </div>
            <div class="ml_39 p_2">
                <a class="btn_1 mr_2 enable" href="/m/quickSetting/SettingNodeStruct">上一步</a><a class="btn_1 mr_2"
                    href="/m/quickSetting/SettingTheme">下一步</a>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function selectType($obj) {
        var type = $obj.find("input[type='hidden']").val();
        $('.js-menu-type > td').each(function (i, n) {
            if ($(n).attr("menu-type") == type) {
                $(n).show().siblings().hide();
            }
        });
    }
    $(document).ready(function () {
        $('.tablelist_style1 .fun a').click(function () {
            $(this).parents('tr').css("background-color", "#eff2f5").siblings().css("background-color", "#ffffff");
            $('.js-refId').val($(this).parent().attr("itemId"));
            $('.js-type').val($(this).attr("type"));
            if ($('.js-showMenu').css("display") != "none") {
                $('.js-showMenu').hide("slow");
            }
            $('.js-showMenu').show("slow");
        });
        if ($('.tablelist_style1 table tr').length > 0) {
            $('.js-showMenu').hide();
        }
        $('.js-menu-type > td').hide();


        function linkMenu() {
            $(".js_link_menu,.js_link_url").click(function (e) {
                var $this = $(this),
                    $radio = $this.find("input");
                if ($radio.is(":checked")) {
                    $this.parent().parent().siblings("tr").find("td input[type='text'],td input[type='hidden']").attr("disabled", "disabled");
                    $this.parent().siblings("td").find("input[type='text']").removeAttr("disabled");
                }
            });
            $(".js_link_menu").bind("click.trigger", function (e) {
                var $this = $(this);
                $this.unbind("click.trigger");
                $.post("/m/quickSetting/GetCurrentMenuList", { menuId: 0 }, function (data) {
                    var $ztreeContainer = $this.parents("th").siblings("td").find(".ztreeContainer_GotoMenu");
                    $ztreeContainer.find("ul").zTreeInit({
                        data: data, trigger: $ztreeContainer.find("input[type='text']"), checkFun: function (treeNode) {
                            var showText = treeNode.name;
                            var tempNode = treeNode;
                            while (tempNode.getParentNode() != null) {
                                tempNode = tempNode.getParentNode();
                                showText = tempNode.name + " > " + showText;
                            }
                            $ztreeContainer.find("input[type='text']").val(showText);
                            $ztreeContainer.find("input[type='hidden']").val(treeNode.id);
                        }
                    }).data("zTree").showZtree();
                });

            });

        }
        linkMenu();
    })
</script>
